
import 'package:get/get.dart';

import '../../../../base/BasePageController.dart';
import '../../../../eneity/AppResponse.dart';
import '../../../../eneity/project_list_entity.dart';

class ProjectListController extends BasePageController {
  var projectLists = <ProjectListDataDatas>[].obs;

  var cid = 0;

  Future<AppResponse<ProjectListEntity>> requestProjectList() async {
    await Future.delayed(const Duration(seconds: 1));
    return apiService.projectList(curPage, cid.toString());
  }

  @override
  void loadData() {
    sendRequest(requestProjectList(), successCallback: (data) {
      projectLists.assignAll(data.datas);
      curPage++;
    });
  }

  @override
  void loadMorePaging() {
    sendLoadMorePagingRequest(requestProjectList(), successBlock: (data) {
      projectLists.addAll(data.datas);
    },judgeNoMoreDataBlock: (data){
      return data?.data.datas.isEmpty ?? true;
    });
  }

  @override
  void refreshPaging() {
    sendRefreshPagingRequest(requestProjectList(), successBlock: (data) {
      projectLists.assignAll(data.datas);
    });
  }
}
